﻿package plugin.npcDialog.ui
{
    import com.core.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import manager.*;
    import plugin.npcDialog.*;
    import plugin.npcDialog.ui.panels.*;
    import plugin.npcDialog.ui.panels.active.*;
    import plugin.npcDialog.ui.panels.boss.*;
    import plugin.npcDialog.ui.panels.deliver.*;
    import plugin.npcDialog.ui.panels.ems.*;
    import plugin.npcDialog.ui.panels.hctwo.*;
    import plugin.npcDialog.ui.panels.td.*;
    import uiresource.*;

    public class NpcDialogUIControl extends NpcDialogUI
    {
        private var mUIBase:NpcDialog;
        private var mCurPanel:INpcDialogContent;
        private var mClassList:Dictionary;
        private var mTypeTitle:Dictionary;
        private var mPanelList:Dictionary;
        private var _curType:String;

        public function NpcDialogUIControl(param1:NpcDialog)
        {
            this.mUIBase = param1;
            this.mClassList = new Dictionary();
            this.mPanelList = new Dictionary();
            this.mTypeTitle = new Dictionary();
            return;
        }// end function

        override protected function createChildren() : void
        {
            loadUI("NpcDialog.xml");
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            btn_close.addEventListener(MouseEvent.CLICK, this.closeHandler);
            this.registerPanel();
            var _loc_1:* = Control.create(NpcDialogControl, this);
            ModelProxy.addObserver("npcdialog", _loc_1);
            return;
        }// end function

        private function registerPanel() : void
        {
            this.mClassList[NpcDialogType.DELIVER] = CSPanel;
            this.mTypeTitle[NpcDialogType.DELIVER] = "传 送";
            this.mClassList[NpcDialogType.EMS] = NpcEMSPanel;
            this.mTypeTitle[NpcDialogType.EMS] = "押 镖";
            this.mClassList[NpcDialogType.TD] = TdPanel;
            this.mTypeTitle[NpcDialogType.TD] = "塔防副本";
            this.mClassList[NpcDialogType.BOSS1] = BossCtrl;
            this.mTypeTitle[NpcDialogType.BOSS1] = "BOSS之家一层";
            this.mClassList[NpcDialogType.BOSS2] = BossCtrl2;
            this.mTypeTitle[NpcDialogType.BOSS2] = "BOSS之家二层";
            this.mClassList[NpcDialogType.WEIZHIANDIAN] = WzadCtrl;
            this.mTypeTitle[NpcDialogType.WEIZHIANDIAN] = "未知暗殿";
            this.mClassList[NpcDialogType.BOSS4] = YQSCtrl;
            this.mTypeTitle[NpcDialogType.BOSS4] = "摇钱树";
            this.mClassList[NpcDialogType.BOSS5] = BOSS5;
            this.mTypeTitle[NpcDialogType.BOSS5] = "尸王殿";
            this.mClassList[NpcDialogType.BOSS6] = BOSSCtrl6;
            this.mTypeTitle[NpcDialogType.BOSS6] = "玛雅神殿";
            this.mClassList[NpcDialogType.Huodong] = ActiveEnter;
            this.mTypeTitle[NpcDialogType.Huodong] = "loading";
            this.mClassList[NpcDialogType.ShenWeiYu] = SwyGame;
            this.mTypeTitle[NpcDialogType.ShenWeiYu] = "神威狱";
            this.mClassList[NpcDialogType.ZhuanShengShenDian] = ZssdGame;
            this.mTypeTitle[NpcDialogType.ZhuanShengShenDian] = "转生福地";
            this.mClassList[NpcDialogType.BOSSHOUSE3] = BossHouse3;
            this.mTypeTitle[NpcDialogType.BOSSHOUSE3] = "BOSS之家三层";
            this.mClassList[NpcDialogType.MAYA2] = MaYa2;
            this.mTypeTitle[NpcDialogType.MAYA2] = "玛雅神殿";
            this.mClassList[NpcDialogType.HUANJING] = HjGame;
            this.mTypeTitle[NpcDialogType.HUANJING] = "幻境";
            this.mClassList[NpcDialogType.HUANJINGTONEXT] = HjToNextGame;
            this.mTypeTitle[NpcDialogType.HUANJINGTONEXT] = "幻境";
            this.mClassList[NpcDialogType.HUANJINGQUIT] = HjQuitGame;
            this.mTypeTitle[NpcDialogType.HUANJINGQUIT] = "幻境";
            this.mClassList[NpcDialogType.MBCZ] = MbczUICtrl;
            this.mTypeTitle[NpcDialogType.MBCZ] = "膜拜城主";
            this.mClassList[NpcDialogType.BOSS7] = CaiLiaoFb;
            this.mTypeTitle[NpcDialogType.BOSS7] = "材料副本";
            this.mClassList[NpcDialogType.RLhecheng] = RLHechengPanel;
            this.mTypeTitle[NpcDialogType.RLhecheng] = "装备熔炼";
            this.mClassList[NpcDialogType.xianliangHCPL] = XianliangHCPL;
            this.mTypeTitle[NpcDialogType.xianliangHCPL] = "限量合成";
            this.mClassList[NpcDialogType.shenzhuangHCPL] = ShenzhuangHCPL;
            this.mTypeTitle[NpcDialogType.shenzhuangHCPL] = "锻造师";
            this.mClassList[NpcDialogType.RxhcPL] = RxhcPL;
            this.mTypeTitle[NpcDialogType.RxhcPL] = "锻造师";
            return;
        }// end function

        public function update(param1:Object) : void
        {
            if (this._curType == param1.type)
            {
                if (this.mCurPanel)
                {
                    this.mCurPanel.update(param1.data);
                }
            }
            return;
        }// end function

        public function openRefresh(param1:Object) : void
        {
            if (!this.mClassList[param1.type])
            {
                return;
            }
            this._curType = param1.type;
            if (this.mCurPanel)
            {
                this.mCurPanel.close();
            }
            if (!this.mPanelList[param1.type])
            {
                this.mPanelList[param1.type] = new this.mClassList[param1.type];
            }
            this.titletxt.text = this.mTypeTitle[param1.type];
            this.mCurPanel = this.mPanelList[param1.type];
            this.container.addChild(this.mCurPanel as DisplayObject);
            this.mCurPanel.show(param1, this);
            var _loc_2:* = param1.npcid;
            var _loc_3:* = ConfigDictionary.data.npc;
            return;
        }// end function

        public function close() : void
        {
            if (this.mCurPanel)
            {
                this.mCurPanel.close();
            }
            this.titletxt.text = "";
            this.mCurPanel = null;
            return;
        }// end function

        public function updatebag() : void
        {
            if (this.mCurPanel is CaiLiaoFb)
            {
                (this.mCurPanel as CaiLiaoFb).updatebag();
            }
            else if (this.mCurPanel is WzadCtrl)
            {
                (this.mCurPanel as WzadCtrl).updatebag();
            }
            else if (this.mCurPanel is ZssdGame)
            {
                (this.mCurPanel as ZssdGame).updatebag();
            }
            else if (this.mCurPanel is HjGame)
            {
                (this.mCurPanel as HjGame).updatebag();
            }
            else if (this.mCurPanel is BOSSCtrl6)
            {
                (this.mCurPanel as BOSSCtrl6).updatebag();
            }
            else if (this.mCurPanel is MaYa2)
            {
                (this.mCurPanel as MaYa2).updatebag();
            }
            return;
        }// end function

        private function closeHandler(event:MouseEvent) : void
        {
            PluginManager.instance.closePlugin("npcdialog");
            return;
        }// end function

    }
}
